home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Programmer Disk
/
The Programmer Disk (Microforum).iso
/
xpro
/
pascal2
/
pro6
/
isdev.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1986-08-04
|
1KB
|
37 lines
(* A slight problem with the code listed in message #22 is that
it will diagnose a text file assigned to a DOS device as a disk
file. To see it for yourself, substitute the name "LPT1" or "COM1"
for the filenames in #22's sample program and watch what results.
The code below will diagnose if the file variable passed is either
thought to be a device by Turbo or DOS. *)
FUNCTION IsDev(VAR FD) : Boolean;
{FD should be the address of a file descriptor; IsDev returns
true if the associated text file is a Turbo or DOS device}
TYPE
FIB = RECORD
handle : Integer;
flags : Byte;
rest : ARRAY[3..75] OF Byte;
END;
RegPack = RECORD
CASE Integer OF
1 : (AX, BX, CX, DX, BP, SI, DI, DS, ES, flags : Integer);
2 : (AL, AH, BL, BH, CL, CH, DL, DH : Byte);
END;
VAR
f : FIB ABSOLUTE FD;
registers : RegPack;
BEGIN
WITH registers DO
BEGIN
AH := $44; {dos i/o control for devices function}
AL := 0; {request device information}
BX := f.handle;
MsDos(registers);
IsDev := ((f.flags AND $F) > 0) OR {turbo thinks it's a device}
(DL > $7F); {dos thinks it's a device}
END;
END;